/*
This file is part of Jumpers.

Jumpers is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

Jumpers is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with Jumpers.  If not, see <http://www.gnu.org/licenses/>.
*/

package org.chaoticengine.cgll.ui;

import java.util.Comparator;
import org.newdawn.slick.GameContainer;
import org.newdawn.slick.Graphics;
import org.newdawn.slick.geom.Rectangle;
import org.newdawn.slick.geom.Vector2f;
import org.newdawn.slick.state.StateBasedGame;

/**
 * An user interface Widget, which is updated whenever the entity or component
 * it gives information about changes. The mechanism used for this is basically
 * the Subject-Observer pattern.
 *
 * @author Matt v.d. Westhuizen
 */
public abstract class Widget {
    public abstract Rectangle getBounds();

    public abstract Integer getPriority();

    public abstract void update();

    public abstract void render(Vector2f position, GameContainer gc,
            StateBasedGame sb, Graphics gr);

    public static Comparator<Widget> getComparator() {
        return(new Comparator<Widget>() {
            public int compare(Widget o1, Widget o2) {
                return(o1.getPriority().compareTo(o2.getPriority()));
            }
        });
    }
}
